package com.yang.dao;

import com.yang.entity.UserNoteInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 用户短信表(UserNoteInfo)表数据库访问层
 *
 * @author yangdacheng
 * @since 2022-03-02 19:11:03
 */
@Mapper
@Repository
public interface UserNoteInfoDao {

    /**
     * 添加新的用户短信
     * @param userNoteInfo
     * @return
     */
    @Insert("INSERT INTO userNoteInfo VALUES(#{noteId},#{userid},#{noteResidue})")
    Boolean insertUserNote(UserNoteInfo userNoteInfo);

    /**
     * 根系用户短信数量
     * @param userNoteInfo
     * @return
     */
    @Update("UPDATE userNoteInfo SET noteResidue = #{noteResidue} WHERE userID=#{userid}")
    Boolean updateUserNote(UserNoteInfo userNoteInfo);

    /**
     * 根据用户编号获取用户短信
     * @param uid
     * @return
     */
    @Results(value = {
            @Result(column = "noteID",property = "noteId",id = true),
            @Result(column = "userID",property = "userid"),
            @Result(column = "noteResidue",property = "noteResidue"),
    },id = "userNoteMapper")
    @Select("SELECT * FROM userNoteInfo WHERE userID=#{uid}")
    UserNoteInfo queryUserNoteByUid(String uid);
}